package homework.day27;

public class Util {
	int limit;

	public int findPrimeCount(int limit) {
		this.limit = limit;
		int cnt1 = 0;
		for(int i = 1 ; i <= limit ; i++)
		{
			int cnt2 = 0;
			for(int j = 1 ; j <= i ; j++)
			{
				if(i % j == 0)
				{
					cnt2++;
				}
			}

			if(cnt2 == 2) cnt1++; 
		} 
		return cnt1;
	}

	public int[] findPrimeReturnArray(int limit) {
		int[] storeArr = new int[this.findPrimeCount(limit)];
		int cnt1 = 0;
		for(int i = 1 ; i <= limit ; i++)
		{
			int cnt2 = 0;
			for(int j = 1 ; j <= i ; j++)
			{
				if(i % j == 0)
				{
					cnt2++;
				}
			}
			if(cnt2 == 2)
			{
				storeArr[cnt1] = i;
				cnt1++;
			}
		} 
		return storeArr;
	}
}
